package com.laan.plat;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.Log;

public class Base {
	
	//posicio
	public float x;
	public float y;
	//tamany
	public float width;
	public float height;
	public float oldWidth;
	//draw options
	Paint paint;
	
	public Base() {
		width = ((float)GV.Screen.metrics.widthPixels*0.2f);
		height = ((float)GV.Screen.metrics.heightPixels*0.05f);
		x = ((float)GV.Screen.metrics.widthPixels/2) - (width/2);
		y = (float)GV.Screen.metrics.heightPixels - 2*height;
		paint = new Paint();
		paint.setColor(0xFF000000);
		paint.setStyle(Paint.Style.FILL);
		oldWidth = width;
	}
	
	public void draw(Canvas canvas) {
		canvas.drawRect(x, y, x+width, y+height, paint);
	}
	
	public void actualitzaPos(float dx) {
//		Log.i("base", String.valueOf(dx));
		
		x += dx;
		if(x<0) x = 0;
		if(x > (float)GV.Screen.metrics.widthPixels - width) x = (float)GV.Screen.metrics.widthPixels-width;
		
//		x += dx;
	}
	
	public void setWidth(float dw) {
//		Log.i("width", String.valueOf(dw));
		width = oldWidth*dw;
	}
	
	public void saveWidth() {
		oldWidth = width;
	}
}
